<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Brokring House RMS Portal</title>
<link rel="stylesheet" type="text/css" href="css/admin.css" />
<!-- <script type="text/javascript" src="js/jquery.min.js"></script>
 --><script type="text/javascript" src="js/ddaccordion.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/pace.css" />
<script type="text/javascript" src="js/pace.js"></script>
<script language="javascript" type="text/javascript" src="js/niceforms.js"></script>

<link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" />
<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader",
	contentclass: "submenu", 
	revealtype: "click", 
	mouseoverdelay: 200, 
	collapseprev: true,
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", ""],
	togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"], 
	animatespeed: "fast", 
	oninit:function(headers, expandedindices){ 
	},
	onopenclose:function(header, index, state, isuseractivated){ 
	}
});

$(document).ready(function() {
	
	
	 done();
	 
	 $('#submit').click(function(event) { 
			var msg=$('input[name=RadioGroup1]:checked').val();
			var uid=document.getElementById("uid").innerHTML;
		var reqUrl="./user/RMSPortal";
				var message=JSON.stringify({"msg":msg,"userId":uid});
			
					$.ajax(
			  		{
			  		type: "POST",
			  		url: reqUrl,
			  		dataType: "json",
			  		contentType: 'application/json',
			  		data:message ,
			  		success: function(jsonData) { 			 
			    	alert("Hello:"+jsonData);
			  		}
					}); 
					});
});

function logout(){
	alert("You are Logout SuccessFully");
	}

function done() {
	  setTimeout( function() { 
	  updates(); 
	  done();
	  }, 800);

}
function updates() {  	
	
	$.get('./user/accountDetail',function(responseJson) {
		
			var table=document.getElementById("RMSPortal");
			 $("#RMSPortal").find("tr").remove();
			  
			var i=1;
			for(var property in responseJson){
				var newRow = document.createElement("tr");
				newRow.id="row"+i;
				
					var oCell1 = document.createElement("td");
						oCell1.id="clientId"+i;
						newRow.appendChild(oCell1);
				
					var oCell2 =document.createElement("td");
				 		var element1 = document.createElement("input");
	             		element1.type = "text";
	             		element1.size="11";
	           			element1.id="totcashfund"+i;
	           			element1.disabled=true;
	            		oCell2.appendChild(element1);
	            		newRow.appendChild(oCell2);
	            		
	             	var oCell3 =document.createElement("td");
					 	var element2 =document.createElement("input");
		             		element2.type = "text";
		           			element2.id="margin"+i;
		           			element2.size="11";
		           			element2.name="margin"+i;
		           			element2.disabled=true;
		           			element2.addEventListener('change', calculate,false);
		            		oCell3.appendChild(element2);
		            		newRow.appendChild(oCell3);
		            		
		          	var oCell4 = document.createElement("td");
		    				
		    				var element3 = document.createElement("input");
		            			element3.type = "text";
		           				element3.id="util"+i;
		           				element3.size="11";
		           				element3.name="util"+i;
		           				element3.disabled=true;
		           			//	element3.addEventListener('change',calculate,false);
		            			oCell4.appendChild(element3);
		            			newRow.appendChild(oCell4);
			           		
			         var oCell5 =  document.createElement("td");
			    				
			    				var element4 = document.createElement("input");
			        			element4.type = "text";
			        			element4.size="11";
			       				element4.id="output"+i;
			       				element4.name="OUTPUT1";
			       				element4.disabled=true;
			        			oCell5.appendChild(element4);
			        			newRow.appendChild(oCell5);
			          
			        var oCell6 = document.createElement("td");
			    		oCell6.id="turnover"+i;
			    		oCell6.innerHTML="20000000";
			    		newRow.appendChild(oCell6);
	            	
			    	var oCell7 = document.createElement("td");
			    		oCell7.id="MTMP_L"+i;
			    		oCell7.innerHTML="-3000";
			    		newRow.appendChild(oCell7);
	            	
	            	var oCell8 = document.createElement("td");
			    		oCell8.id="broke"+i;
			    		newRow.appendChild(oCell8);
	            		
	            	var oCell9 = document.createElement("td");
			    		oCell9.id="totalP_L"+i;
			    		newRow.appendChild(oCell9);
	            		
	            	var oCell10 = document.createElement("td");
			    		oCell10.id="PerP_L"+i;
			    		newRow.appendChild(oCell10);
	            		
	            	var oCell11 = document.createElement("td");
			    		oCell11.id="balFund"+i;
			    		newRow.appendChild(oCell11);
	            		
	            	var oCell12 = document.createElement("td");
	            			var element5 = document.createElement("input");
            				element5.type = "text";
            				element5.size="12";
           					element5.id="trands"+i;
           					element5.name="trands";
           					element5.disabled=true;
           				
            				oCell12.appendChild(element5);
            				newRow.appendChild(oCell12);
	            		
	            	var oCell13 =document.createElement("td");
	    				oCell13.id="color"+i;
	    				newRow.appendChild(oCell13);
	            		
	            	var oCell14 = document.createElement("td");
						oCell14.id="contact"+i;
						newRow.appendChild(oCell14);
						
					var oCell15 = document.createElement("td");
					 oCell15.id="message"+i;
            			var element6 = document.createElement("input");
        				element6.type = "button";
       					element6.value="Message";
       				
        				oCell15.appendChild(element6);
        				newRow.appendChild(oCell15);
		            		
	            	
				 
					table.appendChild(newRow)	;
					for(var a in responseJson[property]){
						document.getElementById("clientId"+i).innerHTML=responseJson[property]["userId"];
						document.getElementById("totcashfund"+i).value=responseJson[property]["cashl"];
						document.getElementById("margin"+i).value=responseJson[property]["marginl"];
						document.getElementById("util"+i).value=responseJson[property]["margin_u"];
						document.getElementById("output"+i).value=responseJson[property]["margin_b"];
						document.getElementById("contact"+i).innerHTML=responseJson[property]["mobile"];
				}
					
			var totalF=responseJson[property]["cashl"]
			var turnO=document.getElementById("turnover"+i).innerHTML;
			var brok=responseJson[property]["brokage"]*turnO/100;
			document.getElementById("broke"+i).innerHTML=brok.toFixed(3);
			var mtm=document.getElementById("MTMP_L"+i).innerHTML;
			var totalP_L=mtm-brok;
			document.getElementById("totalP_L"+i).innerHTML=totalP_L;
			var PerP_L=(totalP_L*100)/responseJson[property]["cashl"];
			document.getElementById("PerP_L"+i).innerHTML=PerP_L.toFixed(3);
			var balFund=Number(totalF)+totalP_L;
			document.getElementById("balFund"+i).innerHTML=balFund;
			
			if(PerP_L>0 && PerP_L<=40)
			{
			document.getElementById('trands'+i).value = "0 to 40%";
			var colors = '#8FBC8F';
			document.getElementById('color'+i).style.backgroundColor = colors;
			}
			else if(PerP_L>40 && PerP_L<=60)
			{
				document.getElementById('trands'+i).value = "40 to 60%";
				var colors = '#556B2F';
				document.getElementById('color'+i).style.backgroundColor = colors;
			}
			else if(PerP_L>60)
			{
				document.getElementById('trands'+i).value = "60% to UP";
				var colors = '#006400';
				document.getElementById('color'+i).style.backgroundColor = colors;
			}
			else if(PerP_L<=0 && PerP_L>(-40))
			{
				document.getElementById('trands'+i).value = "0 to -40%";
				var colors = '#F33939';				
				document.getElementById('color'+i).style.backgroundColor = colors;
				
			}
			else if(PerP_L>(-60) && PerP_L <=(-40))
			{
				document.getElementById('trands'+i).value = "-40 to -60%";

				var colors = '#B51919';
				document.getElementById('color'+i).style.backgroundColor = colors;
			}
			else if(PerP_L>(-101) && PerP_L <=(-60))
			{
				document.getElementById('trands'+i).value = "-60 to -80%";
				var colors = '#860D0D';
				document.getElementById('color'+i).style.backgroundColor = colors;
			}
			
			i++;
			}
	      });
		
	}

function getAjaxObject(){
	try{
		
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
	
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				
				alert("Your browser doesn't suppport Ajax!");
				return false;
			}
		}
	}
	return ajaxRequest;
}
function closeMsgPopUpNew(showDiv){
	document.getElementById(showDiv).style.display	=	'none';
	document.getElementById('blanket').style.display	=	'none';
}
function doSendProfileToFriends(showContentDivID,URL,blanketID){
	var res1=getAjaxObject();
	res1.onreadystatechange=function(){
		if(res1.readyState==4){
			var tt=res1.responseText;
			var resTxtArr = tt.split('~');
			if(tt!=''){
					document.getElementById(showContentDivID).innerHTML=resTxtArr[0];
					document.getElementById("popupDiv").style.display='block';
					document.getElementById(blanketID).style.display = 'block';
			}
			else{
				document.getElementById(showContentDivID).innerHTML=tt;
				document.getElementById(blanketID).style.display = 'block';
			}
		}
	}
	res1.open("GET", URL ,true);
	res1.send(null);
}

function CallPopup(){
	document.getElementById("popUpDiv").style.display = 'block';
	document.getElementById("blanket").style.display = 'block';
}
function Close(){
	document.getElementById("popUpDiv").style.display = 'none';
	document.getElementById("blanket").style.display = 'none';
}
</script>

<style type="text/css">
#blanket {
background-color:#666666;
   opacity: 0.65;
   *background:none;
   position:absolute;
   z-index: 9001;
   top:0px;
   left:0px;
   width:100%;
}
#popUpDiv {
	position:fixed;
	background: #fefefe; 
	
background: -moz-radial-gradient(center, ellipse cover,  #fefefe 0%, #e9e9e9 100%); 
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#fefefe), color-stop(100%,#e9e9e9));
background: -webkit-radial-gradient(center, ellipse cover,  #fefefe 0%,#e9e9e9 100%); 
background: -o-radial-gradient(center, ellipse cover,  #fefefe 0%,#e9e9e9 100%); 
background: -ms-radial-gradient(center, ellipse cover,  #fefefe 0%,#e9e9e9 100%); 
background: radial-gradient(ellipse at center,  #fefefe 0%,#e9e9e9 100%); 
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fefefe', endColorstr='#e9e9e9',GradientType=1 ); 
	width:40%;
	height:auto;
	border:10px solid #4ab5df;
	z-index: 9002;
	top:32%;
	text-align:justify;
	min-height:inherit;
	max-height:inherit;
	float:left;
	left:49%;
	padding:1% 1%;
}

.overlay {    
    bottom: 0;
    cursor: default;
    left: 0;
    opacity: 0;
    position:relative;
    right: 0;
    top: 0;
    z-index: 1;
    -webkit-transition: opacity .5s;
    -moz-transition: opacity .5s;
    -ms-transition: opacity .5s;
    -o-transition: opacity .5s;
    transition: opacity .5s;
}
.overlay:target {
    visibility: visible;
    opacity: 1;
}
.close {
    background-color: rgba(0, 0, 0, 0.8);
    height: 30px;
    line-height: 30px;
    position: absolute;
    right: -5px;
    text-align: center;
    text-decoration: none;
    top: -6px;
    width: 30px;
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    -ms-border-radius: 15px;
    -o-border-radius: 15px;
    border-radius: 15px;
}
.close:before {
    color: rgba(255, 255, 255, 0.9);
    content: "X";
    font-size: 24px;
    text-shadow: 0 -1px rgba(0, 0, 0, 0.9);
}
.close:hover {
    background-color: rgba(64, 128, 128, 0.8);
}

</style>

</head>
<body>
  <%@ include file="header.jsp" %>	
    

    <div class="main_content">
    
                    <div class="menu">
                    <ul>
                    <li><a class="current" href="home">Broker Home</a></li>

                    <li><a href="">Manage Categories</a>
                        <ul>
                        <li><a href="manageacc" title="">Manage Account</a></li>
                        <li><a href="managePwd" title="">Manage Password</a></li>
                       <li><a href="withdrawalreq" title="">Manage WithDraw Request</a></li>
                        <li><a href="" title="">Manage Reports</a></li>
                        
                        </ul>
                    
                    </li>
                    <li><a href="">Manage Users</a>
                   
                        <ul>
                        <li><a href="registrationform" title="">Create User</a></li>
                        <li><a href="account" title="">Client Account Form</a></li>
                        <li><a href="userdetail" >User Details</a></li>
                        <li><a href="" title="">Reports</a>
                       
                            <ul>
                                <li><a href="" title="">Financial Ledger Reports</a></li>
                                <li><a href="" title="">Brok. Details</a></li>
                               
                                <li><a href="" title="">Trade Conf. Details</a></li>
                            </ul>
                      
                        </li>             
                        
                        </ul>
                   
                    </li>
                  
                    <li><a href="">Settings</a>
                  
                     <ul>
                     <li><a href="" title="">Broker Account Setting</a>
                       
                            <ul>
                                <li><a href="Bwithdrawal" title="">Withdrawal Request</a></li>
                                <li><a href="BfundTransfer" title="">Fund Transfer Request</a></li>
                 
                            </ul>
                      
                        </li>             
                        <li><a href="brokeChangePwd" title="">Change Password</a></li>
                        <li><a href="ChangeTransPwd" title="">Change Transaction Password</a></li>    
                     </ul>
                   
                    </li>
            
                    <li><a href="contactus">Contact</a></li>
                    </ul>
                 
                     </div>  
    <div class="center_content">  
    <div id="container1" class="right_content" >            
<div style="border-style:groove; border-width:0px; height:20px; width:1200px;">
<label style=" width:100px;font-size:16px;"><font color="#663380"><b><i>Brokring House RMS Portal</i></b></font></label>
<label style="margin-right:5px; float:right;font-size:16px;" ></label>
</div><br/>


<div id="blanket" class="overlay" style="display:none;"></div>
	<div id="popUpDiv" style="display:none; cursor:pointer; ">
		  Dear  <label id="uid" style="font-size: 15px"></label>
	<form id="form1" name="form1" method="post" action="">
			    <p>
			 
			   <br/>
			      <label><input type="radio" name="RadioGroup1" value="radio1" id="RadioGroup1" />
			      <span style="font-size:14px; font-family:Arial, Helvetica, sans-serif; margin-left:5px;">Radio1</span></label>
			      <br />
			      <label> <input type="radio" name="RadioGroup1" value="radio2" id="RadioGroup2" />
			      <span style="font-size:14px; font-family:Arial, Helvetica, sans-serif; margin-left:5px;">Radio2</span></label>
			      <br />
                  <label> <input type="radio" name="RadioGroup1" value="radio3" id="RadioGroup3" />
                  <span style="font-size:14px; font-family:Arial, Helvetica, sans-serif; margin-left:5px;">Radio3</span></label>
			      <br />
                  <label> <input type="radio" name="RadioGroup1" value="radio4" id="RadioGroup4" />
                  <span style="font-size:14px; font-family:Arial, Helvetica, sans-serif; margin-left:5px;">Radio4</span></label>
			      <br />
                  <label> <input type="radio" name="RadioGroup1" value="radio5" id="RadioGroup5" />
                  <span style="font-size:14px; font-family:Arial, Helvetica, sans-serif; margin-left:5px;">Radio5</span></label>
			      <br />
		        </p>
		        
		        <input type="button" value="Submit" id="submit" style="text-align:center; margin-top:2%;" onclick="Close();" o />
			
		      </form>
        <a class="close" href="#close" onclick="Close();"></a>
	</div>
 <div>
		        
<form name="TESTING">
<div style="overflow: scroll;overflow: auto;width: 1204px;height:300px">
  <table width="100%" border="1" cellpadding="0" cellspacing="0" style="font-family:helvetica; " id="RMSTable" >
<thead>
<tr style='text-align:center' >
			<td ><b>Client Code</b></td>
			 <td ><b>Total Cash Fund</b></td>
			 <td ><b>Margin Limit</b></td>
			 <td ><b>Utilized Limit</b></td>
			 <td ><b>Balance Margin</b></td>
			 <td ><b>Turn Over</b></td>
			 <td ><b>MTM P/L</b></td>
			 <td ><b>Brokage</b></td>
			 <td ><b>Total P/L</b></td>
			 <td ><b>% P/L</b></td>
			 <td ><b>Balance Fund</b></td>
			 <td ><b>Trends</b></td>
			 <td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
			 <td >Contact</td>
			 <td ><b>Message</b></td>
			</tr>
</thead>
<tbody id="RMSPortal"></tbody>
  </table>
  </div>
  </form>
  <script language="javascript">

var table = document.getElementsByTagName("table")[0];
var tbody = table.getElementsByTagName("tbody")[0];
var row = table.getElementsByTagName("tr")[0];

tbody.onclick = function (e) {

    e = e || window.event;
    var data = [];
    var target = e.srcElement || e.target;
    while (target && target.nodeName !== "TR") {
        target = target.parentNode;
		
    }
    if (target) {
	
        var cells = target.getElementsByTagName("td");
      	var i;
        for (i = 0; i < cells.length; i++) {
           data.push(cells[i].innerHTML);
         }
  
        var user=cells[0].innerHTML;
    
        document.getElementById("uid").innerHTML=user; 
   
        if (e.target.type == 'button') {
        
            CallPopup();
          }	
       
    }
  
 
};


</script>
<script type="text/javascript">
function calculate() {
var margin=document.getElementById(b).value;
var util=document.getElementById(b).value;

var CALC1 = margin-util;
document.TESTING.OUTPUT1.value = CALC1;

}


</script>
  </div>         
                    
  </div>        

    <div class="clear"></div>
    <div id="blanket" class="overlay" style="display:none;" onclick="closeMsgPopUpNew('popupDiv')"></div>
 <div id="popupDiv" style="background: #000; height: auto;display:none; float:left;  padding: 0; margin-top:-360px; position: absolute; 
text-align: left; width:50%; margin-left:38%; z-index: 9999;">
 

	 
</div>

   </div> 
</div>    
  <%@ include file="footer.jsp" %>			
</body>
</html>